﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                float m = float.Parse(textBox1.Text);   //当前值
                float n = float.Parse(textBox2.Text);   //比例值

                float c = m * n / 100;  //波动值
                float N1 = m + c;       //上浮
                float N2 = m - c;       //下浮

                //显示四舍五入后的值，保留3位小数
                textBox3.Text = checkBox1.Checked ? N1.ToString("F3") : N1.ToString();
                textBox4.Text = checkBox1.Checked ? N2.ToString("F3") : N2.ToString();
            }
            catch (Exception) { }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            textBox1_TextChanged(null, null);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://git.oschina.net/scimence/FundViewTool/attach_files");
        }
    }
}
